package com.springstudy.imports;


import com.springstudy.beans.OtherBean2;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.Map;

/**
 * @author Tamako
 * @since 2025/1/10 10:56
 */
public class MyImportSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        Map<String, Object> annotationAttributes = importingClassMetadata.getAnnotationAttributes(ComponentScan.class.getName());
//        annotationAttributes.forEach((k, v) -> System.out.println(k + ":" + v));
        String[] basePackages = (String[]) annotationAttributes.get("basePackages");
        System.out.println(basePackages[0]);

        return new String[]{OtherBean2.class.getName()};
    }
}
